import storage from '@/utils/storage'
import constant from '@/utils/constant'

const order = {
	state: {
		deliveryOrderInfo: storage.get(constant.deliveryOrderInfo), // 当前发货订单
		activityGoods: storage.get(constant.activityGoods), // 活动商品
		activitySupplier: storage.get(constant.activitySupplier), // 活动供应商
		oldActivitySupplier: storage.get(constant.oldActivitySupplier), // 活动供应商：暂存旧数据，报名开始后不允许勾掉
		couponSupplier: storage.get(constant.couponSupplier), // 优惠券供应商
		couponGoods: storage.get(constant.couponGoods), // 优惠券商品
	},

	mutations: {
		SET_DELIVERY_ORDERINFO: (state, deliveryOrderInfo) => {
			state.deliveryOrderInfo = deliveryOrderInfo
			storage.set(constant.deliveryOrderInfo, deliveryOrderInfo)
		},
		SET_ACTIVITY_GOODS: (state, activityGoods) => {
			state.activityGoods = activityGoods
			storage.set(constant.activityGoods, activityGoods)
		},
		SET_ACTIVITY_SUPPLIER: (state, activitySupplier) => {
			state.activitySupplier = activitySupplier
			storage.set(constant.activitySupplier, activitySupplier)
		},
		SET_ACTIVITY_OLDSUPPLIER: (state, oldActivitySupplier) => {
			state.oldActivitySupplier = oldActivitySupplier
			storage.set(constant.oldActivitySupplier, oldActivitySupplier)
		},
		SET_COUPON_SUPPLIER: (state, couponSupplier) => {
			state.couponSupplier = couponSupplier
			storage.set(constant.couponSupplier, couponSupplier)
		},
		SET_COUPON_GOODS: (state, couponGoods) => {
			state.couponGoods = couponGoods
			storage.set(constant.couponGoods, couponGoods)
		},
	},

	actions: {}
}

export default order